package com.gz.tomcat;

import com.gz.tomcat.handler.RequestHandler;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

//myTomcat多线程版本(v2)
public class GzTomcatV2 {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8080);
        System.out.println("==========tomcat v2在8080端口监听==========");
        int count=1;
        while (!serverSocket.isClosed()) {
            Socket socket = serverSocket.accept();
            RequestHandler requestHandler = new RequestHandler(socket);
            System.out.println("当前线程= Thread"+count++);
            new Thread(requestHandler).start();
        }
    }
}
